package com.example.patient.jpa;

import com.example.common.entity.ClientBaseInfo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

/**
 * @Author wxy
 * @Date 2021/1/20 15:16
 * @Version 1.0
 */
public interface ClientBaseInfoRepository extends JpaRepository<ClientBaseInfo, Long> {

    ClientBaseInfo findFirstByOpenId(String openId);

    ClientBaseInfo findFirstByPhone(String phone);

    @Query(value = "select count(1) from client_base_info where phone_nvarchar = ?1 and uid_bigint != ?2",nativeQuery = true)
    Long countByPhoneAndUidNotIn(String phone, Long uid);
}
